/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.handlers.commands;

/**
 * This exception is raised by XRENewCommandHandler/XRESetCommandHandler/XREDeleteCommandHandler if it can not find the
 * target XREObject or the XREObject to be associated.
 * <p>
 * Note the exception will only be propagated to XREAggregateCommandHandler and then processed by
 * XRECommandErrorHandler. It extends XREObjectCommandHandlerException.
 * <p>
 * <b>Thread Safety:</b> This class is not thread safe as its base class is not thread safe.
 *
 * @author liuliquan, 7realm
 * @version 1.0
 */
public class XREObjectNotFoundException extends XREObjectCommandHandlerException {
    /** Serial version UID. */
    private static final long serialVersionUID = -4032523769069671012L;
    /**
     * The target ID of XREObject which is not found.
     * <p>
     * Initialized in constructor and will not change after. Can be any value. It has a getter.
     */
    private final int targetId;

    /**
     * Creates a new instance of XREObjectNotFoundException with given error message and the target ID of XREObject
     * which is not found.
     *
     * @param message the error message
     * @param targetId the target ID of XREObject which is not found
     */
    public XREObjectNotFoundException(String message, int targetId) {
        super(message);
        this.targetId = targetId;
    }

    /**
     * Creates a new instance of XREObjectNotFoundException with given error message, the cause and the target ID of
     * XREObject which is not found.
     *
     * @param message the error message
     * @param cause the cause of the exception
     * @param targetId the target ID of XREObject which is not found
     */
    public XREObjectNotFoundException(String message, Throwable cause, int targetId) {
        super(message, cause);
        this.targetId = targetId;
    }

    /**
     * Gets the target ID of XREObject which is not found.
     *
     * @return the target ID of XREObject which is not found
     */
    public int getTargetId() {
        return targetId;
    }
}